package CCF_2013;

import java.util.Arrays;
import java.util.Scanner;

public class T201312_1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = Integer.valueOf(scanner.nextLine());
        String str = scanner.nextLine();
        scanner.close();
        int nums[] = StringToInt(str.split(" "));
        Arrays.sort(nums);
        int maxTimesNum = nums[0];
        int maxTimes = 1;
        int currentNumTimes = 1;
        int currentNum = nums[0];
        for(int i=1;i < count;i++) {
            if(currentNum == nums[i]) {
                currentNumTimes++;
            } else {
                if (currentNumTimes > maxTimes || (currentNumTimes==maxTimes && currentNum < maxTimesNum)) {
                    maxTimesNum = nums[i - 1];
                    maxTimes = currentNumTimes;
                }
                currentNum =  nums[i];
                currentNumTimes = 1;
            }
        }
        if (currentNumTimes > maxTimes || (currentNumTimes==maxTimes && currentNum < maxTimesNum)) {
            maxTimesNum = nums[count-1];
            maxTimes = currentNumTimes;
        }
        System.out.println(maxTimesNum);
    }

    private static int[] StringToInt(String s[]) {
        int array[] = new int[s.length];
        for (int i = 0;i < s.length;i++) {
            array[i] = Integer.valueOf(s[i]);
        }
        return array;
    }
}
